home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
CUJ9202.ARJ
/
1002024B
< prev
next >
Wrap
Text File
|
1992-06-02
|
559b
|
36 lines
main()
{
char op[2];
int i1, i2;
while(1) {
printf("Enter expression: ");
if (scanf("%d %s %d", &i1, op, &i2) == EOF)
break;
push(i1);
push(i2);
if (op[0] == '+')
add();
else if (op[0] == '-')
subtract();
else if (op[0] == '*')
multiply();
else if (op[0] == '/')
divide();
else {
fprintf(stderr, "Unknown operator >%s<\n", op);
pop(); /* discard both operands */
pop();
push(0); /* substitute a zero result */
}
printf("Result = %d\n", pop());
}
return 0;
}